import random
best_weizhi = (4, 0, 2, 6, 8, 1, 3, 5, 7)
win = ((0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), (0, 4, 8), (2, 4, 6))
X = "X"
O = "O"
EMPTY = " "


class Player:
    def __init__(self, name, chess):
        self.name = name
        self.score = 0
        self.chess = chess

    def move(self):             #玩家落子
        position = input('请输入您要下的位置:')




class AIPlayer(Player):
    def move(self):             #电脑落子
        pass




class Board:
    def __init__(self, board_data, movable_list):
        self.board_data = board_data
        self.movable_list = movable_list



    def board(self):            #定义函数产生一个新的棋盘
        board = []
        for square in range(9):
            board.append(EMPTY)
        return board



    def show_board(slef,board):      #显示棋盘
        board2 = board[:]       # 创建副本，修改不影响原来列表board
        for i in range(len(board)):
            if board[i] == EMPTY:
                board2[i] = i
        print("\t", board2[0], "|", board2[1], "|", board2[2])
        print("\t", "---------")
        print("\t", board2[3], "|", board2[4], "|", board2[5])
        print("\t", "---------")
        print("\t", board2[6], "|", board2[7], "|", board2[8], "\n")
     



    def move_down(self, x, y):  #指定落子位置
        pass


    def is_draw(self,board):          #是否平局
        if EMPTY not in board:
            print("平局和棋 游戏结束")
            return 'True'
        return False


    def is_win(self):           #是否胜利
        pass


    def reset_board(self):      #重置棋盘
        pass




#主要流程
class Game:
    def __init__(self):
        self.chess_board = Board()
        self.human = Player()
        self.computer = AIPlayer()

    def random_player(self):        #随机决定先手玩家
        n = random.randint(1,11)
        if n % 2 == 0:      #偶数为电脑先出
            return True
        else:               #奇数为玩家先出
            return False
        


    def play_roun(self):    #完整对局
        pass



    def start(self):        #循环对局
        pass